<?php
/**
 * Created by PhpStorm.
 * User: Inhere
 * Date: 2015/1/29
 * Time: 23:07
 * Use :
 * File: LanguageServiceProvider.php
 */

namespace ulue\base\providers;

use ulue\base\language\Language;
use ulue\core\ioc\Container;

class LanguageServiceProvider extends AbstractConfigurableServiceProvider
{
    public function register(Container $container)
    {
        $config = $this->options;

        $container->share('language', function ( $options ) use ($config)
        {
            $options = is_array($options) ? $options : [];

            if (!isset($options['lang'])) {
                $options['lang'] = \Ulue::$app->language;
            }

            return new Language($options);

        })->alias('system.language')->alias('app.lang')->alias('lang');
    }

}// end class LanguageServiceProvider